# Copyright 2022 Ant Group Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("//bazel:psi.bzl", "psi_cc_binary", "psi_cc_library", "psi_cc_test")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_cc//cc:defs.bzl", "cc_proto_library")

package(default_visibility = ["//visibility:public"])

psi_cc_library(
    name = "labeled_psi",
    srcs = [
        "package.cc",
        "psi_params.cc",
        "receiver.cc",
        "sender.cc",
        "sender_db.cc",
        "sender_kvdb.cc",
        "sender_memdb.cc",
    ],
    hdrs = [
        "package.h",
        "psi_params.h",
        "receiver.h",
        "sender.h",
        "sender_db.h",
        "sender_kvdb.h",
        "sender_memdb.h",
        "serialize.h",
    ],
    deps = [
        ":serializable_cc_proto",
        "//psi/psi/core/ecdh_oprf:ecdh_oprf_selector",
        "//psi/psi/utils:batch_provider",
        "@com_github_microsoft_apsi//:apsi",
        "@com_google_absl//absl/strings",
        "@yacl//yacl/base:exception",
        "@yacl//yacl/crypto/tools:prg",
        "@yacl//yacl/io/kv:leveldb_kvstore",
        "@yacl//yacl/io/kv:memory_kvstore",
        "@yacl//yacl/link",
        "@yacl//yacl/utils:parallel",
    ],
)

proto_library(
    name = "serializable_proto",
    srcs = ["serializable.proto"],
)

cc_proto_library(
    name = "serializable_cc_proto",
    deps = [":serializable_proto"],
)

psi_cc_test(
    name = "apsi_test",
    srcs = [
        "apsi_test.cc",
    ],
    deps = [
        ":labeled_psi",
        "@com_google_absl//absl/strings",
        "@yacl//yacl/crypto/tools:prg",
        "@yacl//yacl/utils:scope_guard",
    ],
)

psi_cc_test(
    name = "apsi_label_test",
    srcs = [
        "apsi_label_test.cc",
    ],
    deps = [
        ":labeled_psi",
        "@com_google_absl//absl/strings",
        "@yacl//yacl/crypto/tools:prg",
        "@yacl//yacl/utils:scope_guard",
    ],
)

psi_cc_test(
    name = "kv_test",
    srcs = [
        "kv_test.cc",
    ],
    deps = [
        ":labeled_psi",
        "//psi/psi/utils",
        "@com_google_absl//absl/strings",
        "@yacl//yacl/crypto/tools:prg",
        "@yacl//yacl/utils:scope_guard",
    ],
)

psi_cc_binary(
    name = "apsi_bench",
    srcs = [
        "apsi_bench.cc",
    ],
    deps = [
        ":labeled_psi",
        "@com_github_google_benchmark//:benchmark_main",
        "@com_google_absl//absl/strings",
        "@com_google_googletest//:gtest",
        "@yacl//yacl/crypto/tools:prg",
    ],
)
